<!-- CREATE VIEW options -->
<div id="div_view_options">
  <form method="post" action="{{ url('/view/create') }}" class="card">
    {{ get_hidden_inputs(url_params) }}
    <input type="hidden" name="ajax_request" value="1">
    <input type="hidden" name="{{ (view['operation'] == 'create') ? 'createview' : 'alterview' }}" value="1">
    <input type="hidden" name="ajax_dialog" value="1">

    <div class="card-header">
      {% if ajax_dialog %}
        {{ t('Details') }}
      {% else %}
        {% if view['operation'] == 'create' %}
          {{ t('Create view') }}
        {% else %}
          {{ t('Edit view') }}
        {% endif %}
      {% endif %}
    </div>

    <div class="card-body">
      <table class="table align-middle rte_table">
        <colgroup>
          <col>
          <col width="100%">
        </colgroup>

        {% if view['operation'] == 'create' %}
          <tr>
            <td class="text-nowrap"><label for="or_replace">OR REPLACE</label></td>
            <td>
              <input type="checkbox" name="view[or_replace]" id="or_replace"
                {% if (view['or_replace']) %} checked {% endif %}
                     value="1">
            </td>
          </tr>
        {% endif %}

        <tr>
          <td class="text-nowrap"><label for="algorithm">ALGORITHM</label></td>
          <td>
            <select name="view[algorithm]" id="algorithm">
              {% for option in view_algorithm_options %}
                <option value="{{ option }}"
                  {% if view['algorithm'] == option %}
                    selected
                  {% endif %}
                >{{ option }}</option>
              {% endfor %}
            </select>
          </td>
        </tr>

        <tr>
          <td class="text-nowrap">{{ t('Definer') }}</td>
          <td><input type="text" maxlength="100" size="50" name="view[definer]" value="{{ view['definer'] }}"></td>
        </tr>

        <tr>
          <td class="text-nowrap">SQL SECURITY</td>
          <td>
            <select name="view[sql_security]">
              <option value=""></option>
              {% for option in view_security_options %}
                <option value="{{ option }}"
                  {% if option == view['sql_security'] %} selected {% endif %}
                >{{ option }}</option>
              {% endfor %}
            </select>
          </td>
        </tr>

        {% if view['operation'] == 'create' %}
          <tr>
            <td class="text-nowrap">{{ t('VIEW name') }}</td>
            <td>
              <input type="text" size="20" name="view[name]" onfocus="this.select()" maxlength="64" value="{{ view['name'] }}">
            </td>
          </tr>
        {% else %}
          <tr>
            <td>
              <input type="hidden" name="view[name]" value="{{ view['name'] }}">
            </td>
          </tr>
        {% endif %}

        <tr>
          <td class="text-nowrap">{{ t('Column names') }}</td>
          <td>
            <input type="text" maxlength="100" size="50" name="view[column_names]" onfocus="this.select()" value="{{ view['column_names'] }}">
          </td>
        </tr>

        <tr>
          <td class="text-nowrap">AS</td>
          <td>
            <textarea name="view[as]" id="view_as" rows="15" cols="40" dir="{{ pma.text_dir }}">{{ view['as'] }}</textarea><br>
            <input type="button" value="Format" id="format" class="btn btn-secondary button sqlbutton">
            <span id="querymessage"></span>
          </td>
        </tr>

        <tr>
          <td class="text-nowrap">WITH CHECK OPTION</td>
          <td>
            <select name="view[with]">
              <option value=""></option>
              {% for option in view_with_options %}
                <option value="{{ option }}"
                  {% if option == view['with'] %} selected {% endif %}
                >{{ option }}</option>
              {% endfor %}
            </select>
          </td>
        </tr>

      </table>
    </div>

    {% if ajax_dialog == false %}
      <div class="card-footer">
        <input type="submit" class="btn btn-primary" name="" value="{{ t('Go') }}">
      </div>
    {% endif %}
  </form>
</div>
